import java.io.*;

import javax.swing.JOptionPane;


public class YTSubDifferences
{
	public static void main(String args[]) throws IOException
	{
		try
		{
			// Open the file that is the first 
			// command line parameter
			FileInputStream f1stream = new FileInputStream("out2.txt");
			// Get the object of DataInputStream
			DataInputStream in1 = new DataInputStream(f1stream);
			BufferedReader br1 = new BufferedReader(new InputStreamReader(in1));
			String strLine1;
			
			// Open the file that is the first 
			// command line parameter
			FileInputStream f2stream = new FileInputStream("out1.txt");
			// Get the object of DataInputStream
			DataInputStream in2 = new DataInputStream(f2stream);
			BufferedReader br2 = new BufferedReader(new InputStreamReader(in2));
			String strLine2;
			
			// Create file
			FileWriter ostream = new FileWriter("diff.txt",false);
			BufferedWriter out = new BufferedWriter(ostream);
			
			//Read File Line By Line
			
			String content = "";

			while (((strLine1 = br1.readLine()) != null))
			{
				content += (strLine1 + "\n");
			}
			
			while (((strLine2 = br2.readLine()) != null))
			{
				if(content.indexOf(strLine2) == -1)
				{
					System.out.println(strLine2);
					out.write(strLine2 + "\n");
				}
			}
			
			//Close the input stream
			in1.close();
			in2.close();
			//Close the output stream
			out.close();
		}catch (Exception e)
		{//Catch exception if any
			JOptionPane.showMessageDialog(null,"You will need to run 'YTSubCount.jar' twice first to generate your first and second files.");
			System.err.println("Error: " + e.getMessage());
		}
		JOptionPane.showMessageDialog(null,"Done");
	}
}
